
class LixinPlugin:
	def __init__(self):
		# put all the links this plugins supports here - it will be used to filter supported URLs
		self.supported_sites = ['lix.in']
		# the URLs we support
		self.supported_urls = self.supported_sites
		self.cookies_to_block = []

	def get(self, url):
		"""Get the file from the url"""
		remote_url = ''
		post_data = {'tiny': url.split('/')[-1].strip('/'),
			'submit': 'continue'}
		for line in urllib2.urlopen(url, urllib.urlencode(post_data)).read().splitlines():
			if line.find('src=') != -1:
				remote_url = line.split('src="')[1].split('"')[0].strip(' \r\n')
				break

		if not remote_url:
			raise CantDownload('Error occured while trying to download')
		get_with_retry(remote_url)

	def url_matches(self, url):
		"""Check whether we support this URL"""
		# see if the url contains a substring we are looking for
		for l in self.supported_urls:
			if url.find(l) != -1:
				return True
		return False

	def version(self):
		"""Return plugin version - when interface changes, the version changes"""
		return 1

modules = [LixinPlugin()]
